package com.saturn.action.highcharts;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.saturn.app.web.IAction;
import com.saturn.app.web.IView;
import com.saturn.app.web.view.JsonView;
import com.saturn.highcharts.Bar;

public class ListBarDatasAction implements IAction {

	@Override
	public IView execute(HttpServletRequest request,
			HttpServletResponse response) {
		
		Bar ct1 = new Bar();
		String[] data1 = {107+"", 31+"", 635+"", 203+"", 2+""};
		ct1.setName("Year 1800");
		ct1.setData(data1);
		
		Bar ct2 = new Bar();
		String[] data2 = {133+"", 156+"", 947+"", 408+"", 6+""};
		ct2.setName("Year 1900");
		ct2.setData(data2);
		
		Bar ct3 = new Bar();
		String[] data3 = {973+"", 914+"", 4054+"", 732+"", 34+""};
		ct3.setName("Year 2008");
		ct3.setData(data3);
		
		List<Bar> cts = new ArrayList<Bar>();
		cts.add(ct1);
		cts.add(ct2);
		cts.add(ct3);
		return new JsonView(Bar.getBarJSON(cts));
	}
	
	@Override
	public String requestMapping() {
		return "/highcharts/listBarDatas.action";
	}


}
